package com.ruoyi.web.controller.invoice;

import com.ruoyi.dto.IdDto;
import com.ruoyi.third.base.InvoiceApiResult;
import com.ruoyi.third.entity.request.BuyerAdd;
import com.ruoyi.third.entity.request.BuyerEdit;
import com.ruoyi.third.entity.request.BuyerSearch;
import com.ruoyi.third.entity.request.BuyerSearchBlur;
import com.ruoyi.third.service.ThirdApiService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@Api(tags = "购货方")
@RestController
@AllArgsConstructor
@RequestMapping("invoice/buyer")
public class BuyerController {

    private final ThirdApiService thirdApiService;

    @ApiOperation(value = "购货方查询", httpMethod = "POST")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "nsrmc", value = "纳税人名称", dataTypeClass = String.class),
            @ApiImplicitParam(name = "jm", value = "简码", dataTypeClass = String.class)
    })
    @PostMapping("buyerSearch")
    public InvoiceApiResult buyerSearch(@RequestBody @Validated BuyerSearch param) {
        return thirdApiService.buyerSearch(param);
    }


    @ApiOperation(value = "模糊查询购货单位此信息", httpMethod = "POST")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "BuyerSearchBlur", value = "BuyerSearchBlur", dataTypeClass = BuyerSearchBlur.class)
    })
    @PostMapping("buyerSearchBlur")
    public InvoiceApiResult buyerSearchBlur(@RequestBody @Validated BuyerSearchBlur param) {
        return thirdApiService.buyerSearchBlur(param);
    }

    @ApiOperation(value = "购货方新增", httpMethod = "POST")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "BuyerAdd", value = "BuyerAdd", dataTypeClass = BuyerAdd.class)
    })
    @PostMapping("buyerAdd")
    public InvoiceApiResult buyerAdd(@RequestBody @Validated BuyerAdd param) {
        return thirdApiService.buyerAdd(param);
    }

    @ApiOperation(value = "购货方修改", httpMethod = "POST")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "BuyerEdit", value = "BuyerEdit", dataTypeClass = BuyerEdit.class)
    })
    @PostMapping("buyerEdit")
    public InvoiceApiResult buyerEdit(@RequestBody @Validated BuyerEdit param) {
        return thirdApiService.buyerEdit(param);
    }

    @ApiOperation(value = "购货方删除", httpMethod = "POST")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "id", dataTypeClass = String.class)
    })
    @PostMapping("buyerDel")
    public InvoiceApiResult buyerDel(@RequestBody @Validated IdDto param) {
        return thirdApiService.buyerDel(param.getId());
    }


}
